<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#assign css>

</#assign>
<#assign js>
<script src="/assets/vendor/ueditor/ueditor.config.js" ></script>
<script src="/assets/vendor/ueditor/ueditor.all.js" ></script>
<script>
    var ue = UE.getEditor('content_');


    $(".btn-submit").click(function () {

		// 校验表单合法
		var bootstrapValidator = $(".form-edit").data('bootstrapValidator');
		//bootstrapValidator.validate();

        $.ajax({
            type: "POST",
            dataType: "json",
            url: "/content/edit",
            data: $(".form-edit").serialize(),
            success: function(res){
                layer.msg(res.message, {time: 2000
                }, function(){
                    location.href="/content/index";
                });
            },
            error:function(){
                layer.msg("shibai ");
            }
        });
    });


</script>
</#assign>
<@layout title="内容编辑" active="content">
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        内容管理
        <small>编辑</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="/"><i class="fa fa-home"></i> 内容管理</a></li>
        <li class="active"><i class="fa fa-edit"></i> 编辑</li>
    </ol>
</section>
<!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <!-- Default box -->
            <div class="box  box-primary">
                <form class="form-horizontal form-edit" id="frm" method="post" action="/content/edit">
                    <div class="box-body">
                        <input type="hidden" id="id" name="id" value="${content.id!}">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">协议类型：</label>
                            <div class="col-sm-8">
                                <input id="type"  name="phoneNumber" class="form-control" type="text" value="${typeEnum[content.type].desc!}" disabled>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">协议内容：</label>
                            <div class="col-sm-8">
                                <#if content.type ==8>
                                    <input id="content" name="content" class="form-control" type="text" value="${content.content!}">
                                <#elseif content.type ==14>
                                    <textarea id="content" name="content" class="form-control" type="text" rows="10">${content.content!}</textarea>
                                <#else >
                                    <script id="content_" name="content" type="text/plain">
                                        ${content.content!}
                                    </script>

                                </#if>

                            </div>
                        </div>



                    </div>
                    <div class="box-footer">
                        <button type="button" class="btn btn-default btn-back">返回</button>
                        <button type="button" class="btn btn-info pull-right btn-submit">提交</button>
                    </div>
                </form>
            </div>
            <!-- /.box -->
        </div>
    </div>
</section>
<!-- /.content -->
</@layout>